package com.yztl.service.admin;


import com.yztl.mapper.admin.AdminMapper;
import com.yztl.pojo.*;
import com.yztl.util.PageUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class AdminServiceImpl implements AdminService{
    @Resource
    private AdminMapper adminMapper;


    @Override
    public Admin AdminLogin(String admin_name, String admin_userpassword) {
        return adminMapper.AdminLogin(admin_name,admin_userpassword);
    }

    @Override
    public void getPageClient(PageUtil<Client> pageUtil, int customer_adminid) {
            int count=adminMapper.getCount(customer_adminid);
        pageUtil.setCounts(count);
        if(count>0){
            if(pageUtil.getPageIndex()>pageUtil.getPageCount()){//右边界
                pageUtil.setPageIndex(pageUtil.getPageCount());
            }
            int pageindex=(pageUtil.getPageIndex()-1)*pageUtil.getPageSize();
            int pagesize=pageUtil.getPageSize();
            pageUtil.setLists(adminMapper.getPageClient(pageindex,pagesize,customer_adminid));
            List<Client> lists = pageUtil.getLists();
        }else{
            pageUtil.setLists(new ArrayList<>());
        }
    }

    @Override
    public int deleteOrder(int id, int order_state) {
        return adminMapper.deleteOrder(id,order_state);
    }

    @Override
    public int getCount(int id) {
        return adminMapper.getCount(id);
    }

    @Override
    public Client selOne(int adminId) {
        return adminMapper.selOne(adminId);
    }

    @Override
    public List<Status> getStatus() {
        return adminMapper.getStatus();
    }

    @Override
    public List<Product> getProduct() {
        return adminMapper.getProduct();
    }

    @Override
    public int updClient(Client client) {
        return adminMapper.updClient(client);
    }

    @Override
    public int updOrder(Order order) {
        return adminMapper.updOrder(order);
    }

    @Override
    public int addClient(Client client) {
        return adminMapper.addClient(client);
    }




}
